//
//  NSString+EX.m
//  iShow
//
//  Created by nsm on 2018/8/16.
//  Copyright © 2018年 nani. All rights reserved.
//

#import "NSString+EX.h"

@implementation NSString (EX)
// MARK: 正则判断
- (NSString *)regexString:(NSMRegexOption)regexOption {
    NSDictionary *regexDic;
    regexDic = @{@"0": @"^[A-Za-z]+$",  // 是否以字母开头
                 };
    NSString *regexKey = [NSString stringWithFormat:@"%ld",(long)regexOption];
    return regexDic[regexKey];
}

- (BOOL)regex:(NSMRegexOption)regexOption {
    NSString *regex = [self regexString:regexOption];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    return [predicate evaluateWithObject:self];
}
@end
